Skip to content

fix: preserve source when removing nested values - #807

Merged
yoyo837 merged 2 commits into
react-component:masterfrom
nrps9909:codex/preserve-set-source
Sep 20, 2026
Merged

yoyo837 merged 2 commits into
react-component:masterfrom
nrps9909:codex/preserve-set-source

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • clone the nested container before removeIfUndefined deletes its leaf
  • preserve the input object and a new reference along the changed path
  • add a regression assertion for both immutability and child identity

Why

internalSet cloned the root, but the deletion branch still mutated the original nested container through the shared clone[path] reference. Consumers that compare previous and next nested values can consequently miss the removal. This is the underlying cause reproduced from ant-design/ant-design#59044.

Verification — September 20, 2026

Follow-up at signed/GitHub-Verified head 1b00e46db84c0861738904f935c2bdee845ffee0.

Confirmed the primitive-parent edge case and added a type guard before cloning the nested parent. Five regressions (string, number, boolean, symbol and bigint) fail on the previous head and pass with this fix; object-removal immutability remains covered. Full run: 30 suites / 202 tests pass, 1 skipped. TypeScript, ESM/CJS/declaration build and focused lint/format checks pass.

Remote checks for this new commit are separate from the local results above.

AI assistance disclosure

Codex assisted with implementation, conflict resolution, regression tests, and validation.

Summary by CodeRabbit

  • 错误修复
    • 修复删除嵌套属性时可能直接修改原对象的问题。
    • 删除对象或数组中的嵌套属性时,会返回更新后的新对象,并保留原对象及其嵌套数据不变。
    • 当源值为字符串、数字、布尔值、Symbol 或 BigInt 时,删除不存在的属性不会改变其值。
    • 当源对象为空值时,不再因删除操作抛出错误。

@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

@nrps9909 is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 636e4b61-1ac3-4433-bedf-aeb8f24bcf61

📥 Commits

Reviewing files that changed from the base of the PR and between 4bef120 and 1b00e46.

📒 Files selected for processing (2)
  • src/utils/set.ts
  • tests/utils.test.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


Walkthrough

删除未定义的嵌套属性时,internalSet 仅对对象或数组执行复制、删除和写回。测试覆盖嵌套对象不可变性,以及字符串、数字、布尔、Symbol 和 BigInt 等基本类型值。

Changes

安全删除嵌套属性

Layer / File(s) Summary
保护嵌套值并验证删除行为
src/utils/set.ts, tests/utils.test.ts
internalSet 在目标值为对象或数组时创建浅副本,再删除属性并写回。测试验证源对象不变、返回对象使用新的嵌套引用,并确认基本类型值保持不变。

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:删除嵌套值时保留源对象。标题简洁、明确,并与代码和测试变更一致。
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

小兔检查嵌套枝,
先把对象轻轻复制。
空值不再引发错误,
基本类型保持原样,
新旧引用各自安稳。

Comment @coderabbitai help to get the list of available commands.

@yoyo837

yoyo837 commented Sep 17, 2026

Copy link
Copy Markdown
Member

Rebase please.

@nrps9909
nrps9909 force-pushed the codex/preserve-set-source branch from 29a9884 to 4bef120 Compare September 17, 2026 08:17
@nrps9909

Copy link
Copy Markdown
Contributor Author

Rebased onto current master (c241125); signed/GitHub-Verified head: 4bef1200164cd7bc98d9743248dffd9ec5abf306.

  • Full suite: 30 suites, 197 tests passed; 1 test skipped.
  • TypeScript, ESM/CJS/declaration build, focused ESLint (0 errors), Prettier and diff checks passed.
  • GitHub signatures and changed-file blobs were checked against the local branch.
  • Includes upstream fix: resolve pre-existing test failures on master #815, which fixes the prior pickAttrs and React-17 fallback test failures.
  • Upstream CI: ✅ test currently action_required. A maintainer must approve the fork workflow before it can run.
  • Vercel preview still requires upstream team authorization.

@codecov

codecov Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.83%. Comparing base (c241125) to head (1b00e46).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #807      +/-   ##
==========================================
+ Coverage   86.77%   86.83%   +0.06%     
==========================================
  Files          41       41              
  Lines        1096     1101       +5     
  Branches      397      399       +2     
==========================================
+ Hits          951      956       +5     
  Misses        143      143              
  Partials        2        2              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yoyo837

yoyo837 commented Sep 17, 2026

Copy link
Copy Markdown
Member

Non-blocking edge case: if the parent path value is a truthy primitive (e.g. set({ keep: 'str' }, ['keep', 'light'], undefined, true)), the new { ...origin } spread turns the string into a char-indexed object, whereas the old code was a no-op. The get guard in set() filters null/undefined but not truthy primitives. Unlikely in practice since parents are objects/arrays, but a typeof origin === 'object' check before copying would make it airtight.

@nrps9909

nrps9909 commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Follow-up at signed/GitHub-Verified head 1b00e46db84c0861738904f935c2bdee845ffee0.

Confirmed the primitive-parent edge case and added a type guard before cloning the nested parent. Five regressions (string, number, boolean, symbol and bigint) fail on the previous head and pass with this fix; object-removal immutability remains covered. Full run: 30 suites / 202 tests pass, 1 skipped. TypeScript, ESM/CJS/declaration build and focused lint/format checks pass.

CI update: the exact-head test workflow, React Doctor, CodeQL, Surge preview, and both Codecov patch/project checks pass. The only remaining failed status is Vercel team authorization.

@yoyo837
yoyo837 merged commit 993255e into react-component:master Sep 20, 2026
11 of 12 checks passed
aibayanyu20 added a commit to antdv-next/vue-components that referenced this pull request Sep 25, 2026
…component/util#807)

- copy the parent object / array before deleting with removeIfUndefined
- skip deletion when the parent is missing or a primitive
- add set tests for source immutability and primitive parents

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kallesiukolaa pushed a commit to Technarion-Oy/thaw that referenced this pull request Oct 26, 2026
This PR contains the following updates:

| Package | Change |
[Age](https://docs.renovatebot.com/merge-confidence/) |
[Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [antd](https://ant.design)
([source](https://redirect.github.com/ant-design/ant-design)) | [`6.6.6`
→ `6.6.7`](https://renovatebot.com/diffs/npm/antd/6.6.6/6.6.7) |
![age](https://developer.mend.io/api/mc/badges/age/npm/antd/6.6.7?slim=true)
|
![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/antd/6.6.6/6.6.7?slim=true)
|

---

### Release Notes

<details>
<summary>ant-design/ant-design (antd)</summary>

###
[`v6.6.7`](https://redirect.github.com/ant-design/ant-design/releases/tag/6.6.7)

[Compare
Source](https://redirect.github.com/ant-design/ant-design/compare/6.6.6...6.6.7)

- 🐞 Fix antd failing to load in some production builds when the React
version export is unavailable.
[#&#8203;59560](https://redirect.github.com/ant-design/ant-design/pull/59560)
[react-component/util#810](https://redirect.github.com/react-component/util/pull/810)
[@&#8203;github-actions](https://redirect.github.com/apps/github-actions)
[@&#8203;nrps9909](https://redirect.github.com/nrps9909)
- 🐞 Fix Button, Form, Slider, Typography, and Upload triggering delayed
state updates after unmounting.
[#&#8203;59560](https://redirect.github.com/ant-design/ant-design/pull/59560)
[react-component/util#806](https://redirect.github.com/react-component/util/pull/806)
[@&#8203;github-actions](https://redirect.github.com/apps/github-actions)
[@&#8203;nrps9909](https://redirect.github.com/nrps9909)
- 🐞 Fix Select, TreeSelect, Cascader, and Mentions `popupRender` content
inheriting Form.Item validation status and feedback icons.
[#&#8203;59463](https://redirect.github.com/ant-design/ant-design/pull/59463)
[@&#8203;huytdps13400](https://redirect.github.com/huytdps13400)
- 🐞 Fix Popover and Popconfirm preset `color` not applying to the panel
background.
[#&#8203;59549](https://redirect.github.com/ant-design/ant-design/pull/59549)
[@&#8203;dogledogle](https://redirect.github.com/dogledogle)
- Form
- 🐞 Fix Form custom `shouldUpdate` comparisons missing updates when
nested fields with `preserve={false}` are unmounted.
[#&#8203;59560](https://redirect.github.com/ant-design/ant-design/pull/59560)
[react-component/util#807](https://redirect.github.com/react-component/util/pull/807)
[@&#8203;github-actions](https://redirect.github.com/apps/github-actions)
[@&#8203;nrps9909](https://redirect.github.com/nrps9909)
- 🐞 Fix Form.Item incorrectly removing a trailing `|` from a string
`label` when displaying a colon.
[#&#8203;59599](https://redirect.github.com/ant-design/ant-design/pull/59599)
[@&#8203;wfatih](https://redirect.github.com/wfatih)
- ⌨️ Fix Form.Item not associating warning-only messages with the
control through `aria-describedby`.
[#&#8203;59443](https://redirect.github.com/ant-design/ant-design/pull/59443)
[@&#8203;Chaoqi31](https://redirect.github.com/Chaoqi31)
- Input
- 🐞 Fix Input.OTP losing valid characters when pasting text with a
filtering `formatter`.
[#&#8203;59580](https://redirect.github.com/ant-design/ant-design/pull/59580)
[@&#8203;yunfeizhu](https://redirect.github.com/yunfeizhu)
- 🐞 Fix Input.OTP ignoring `rootClassName` on the root element.
[#&#8203;59439](https://redirect.github.com/ant-design/ant-design/pull/59439)
[@&#8203;Chaoqi31](https://redirect.github.com/Chaoqi31)
- 🐞 Fix Input.OTP not rendering a numeric `0` as the `separator`.
[#&#8203;59518](https://redirect.github.com/ant-design/ant-design/pull/59518)
[@&#8203;Ye-YiChen](https://redirect.github.com/Ye-YiChen)
- Table
- 🐞 Fix Table selection menu skipping current-page tree descendants when
inverting selection and deselecting disabled rows on other pages when
clearing selections.
[#&#8203;59570](https://redirect.github.com/ant-design/ant-design/pull/59570)
[@&#8203;yunfeizhu](https://redirect.github.com/yunfeizhu)
- 🐞 Fix Table sorted fixed header hover background and the
`fixedHeaderSortActiveBg` token not taking effect.
[#&#8203;59554](https://redirect.github.com/ant-design/ant-design/pull/59554)
[@&#8203;dogledogle](https://redirect.github.com/dogledogle)
- ColorPicker
- 🐞 Fix ColorPicker applying RTL styles when ConfigProvider `direction`
is `ltr`.
[#&#8203;59441](https://redirect.github.com/ant-design/ant-design/pull/59441)
[@&#8203;Chaoqi31](https://redirect.github.com/Chaoqi31)
- 🐞 Fix ColorPicker number input control button width.
[#&#8203;59538](https://redirect.github.com/ant-design/ant-design/pull/59538)
[@&#8203;QDyanbing](https://redirect.github.com/QDyanbing)
- 🐞 Fix nested Descriptions being affected by the outer component's
borders, spacing, and cell layout.
[#&#8203;59547](https://redirect.github.com/ant-design/ant-design/pull/59547)
[@&#8203;xushanpei](https://redirect.github.com/xushanpei)
- 🐞 Fix Progress line ignoring string widths in `size`, such as `['50%',
20]`, and always filling the container.
[#&#8203;59597](https://redirect.github.com/ant-design/ant-design/pull/59597)
[@&#8203;wfatih](https://redirect.github.com/wfatih)
- 🐞 Fix Tooltip failing to limit panel corner radius to 8px for left and
right placements when the `borderRadius` token exceeds 8.
[#&#8203;59568](https://redirect.github.com/ant-design/ant-design/pull/59568)
[@&#8203;dogledogle](https://redirect.github.com/dogledogle)
- 🐞 Fix Popconfirm `onPopupClick` firing twice for a single click inside
the popup content.
[#&#8203;59440](https://redirect.github.com/ant-design/ant-design/pull/59440)
[@&#8203;Chaoqi31](https://redirect.github.com/Chaoqi31)
- 🐞 Fix Upload extra content styles when `showUploadList.extra` is `0`
or returns `0`.
[#&#8203;59438](https://redirect.github.com/ant-design/ant-design/pull/59438)
[@&#8203;Chaoqi31](https://redirect.github.com/Chaoqi31)
- ♿ Fix Typography duplicate button semantics for the default edit icon.
[#&#8203;59112](https://redirect.github.com/ant-design/ant-design/pull/59112)
[@&#8203;nrps9909](https://redirect.github.com/nrps9909)
- ⚡️ Improve Transfer source list rendering performance.
[#&#8203;59524](https://redirect.github.com/ant-design/ant-design/pull/59524)
[@&#8203;QDyanbing](https://redirect.github.com/QDyanbing)

***

- 🐞 修复 antd 在部分生产构建中因 React
版本信息缺失而加载失败的问题。[#&#8203;59560](https://redirect.github.com/ant-design/ant-design/pull/59560)
[react-component/util#810](https://redirect.github.com/react-component/util/pull/810)
[@&#8203;github-actions](https://redirect.github.com/apps/github-actions)
[@&#8203;nrps9909](https://redirect.github.com/nrps9909)
- 🐞 修复 Button、Form、Slider、Typography 和 Upload
在卸载后仍触发延迟状态更新的问题。[#&#8203;59560](https://redirect.github.com/ant-design/ant-design/pull/59560)
[react-component/util#806](https://redirect.github.com/react-component/util/pull/806)
[@&#8203;github-actions](https://redirect.github.com/apps/github-actions)
[@&#8203;nrps9909](https://redirect.github.com/nrps9909)
- 🐞 修复 Select、TreeSelect、Cascader 和 Mentions 的 `popupRender` 内容继承
Form.Item
校验状态和反馈图标的问题。[#&#8203;59463](https://redirect.github.com/ant-design/ant-design/pull/59463)
[@&#8203;huytdps13400](https://redirect.github.com/huytdps13400)
- 🐞 修复 Popover 和 Popconfirm 设置预设 `color`
后面板背景色不生效的问题。[#&#8203;59549](https://redirect.github.com/ant-design/ant-design/pull/59549)
[@&#8203;dogledogle](https://redirect.github.com/dogledogle)
- Form
- 🐞 修复 Form 嵌套字段设置 `preserve={false}` 后卸载时,自定义 `shouldUpdate`
判断可能无法更新关联内容的问题。[#&#8203;59560](https://redirect.github.com/ant-design/ant-design/pull/59560)
[react-component/util#807](https://redirect.github.com/react-component/util/pull/807)
[@&#8203;github-actions](https://redirect.github.com/apps/github-actions)
[@&#8203;nrps9909](https://redirect.github.com/nrps9909)
- 🐞 修复 Form.Item 显示冒号时误删字符串 `label` 末尾 `|`
的问题。[#&#8203;59599](https://redirect.github.com/ant-design/ant-design/pull/59599)
[@&#8203;wfatih](https://redirect.github.com/wfatih)
- ⌨️ 修复 Form.Item 仅有警告信息时未通过 `aria-describedby`
关联到控件的问题。[#&#8203;59443](https://redirect.github.com/ant-design/ant-design/pull/59443)
[@&#8203;Chaoqi31](https://redirect.github.com/Chaoqi31)
- Input
- 🐞 修复 Input.OTP 使用过滤型 `formatter`
时粘贴文本会丢失有效字符的问题。[#&#8203;59580](https://redirect.github.com/ant-design/ant-design/pull/59580)
[@&#8203;yunfeizhu](https://redirect.github.com/yunfeizhu)
- 🐞 修复 Input.OTP 根节点未应用 `rootClassName`
的问题。[#&#8203;59439](https://redirect.github.com/ant-design/ant-design/pull/59439)
[@&#8203;Chaoqi31](https://redirect.github.com/Chaoqi31)
- 🐞 修复 Input.OTP 无法渲染数值 `0` 作为 `separator`
的问题。[#&#8203;59518](https://redirect.github.com/ant-design/ant-design/pull/59518)
[@&#8203;Ye-YiChen](https://redirect.github.com/Ye-YiChen)
- Table
- 🐞 修复 Table
选择菜单反选时遗漏当前页树形子节点,以及清空选择时取消其他页禁用行选中状态的问题。[#&#8203;59570](https://redirect.github.com/ant-design/ant-design/pull/59570)
[@&#8203;yunfeizhu](https://redirect.github.com/yunfeizhu)
- 🐞 修复 Table 固定排序表头悬停背景异常及 `fixedHeaderSortActiveBg` token
不生效的问题。[#&#8203;59554](https://redirect.github.com/ant-design/ant-design/pull/59554)
[@&#8203;dogledogle](https://redirect.github.com/dogledogle)
- ColorPicker
- 🐞 修复 ConfigProvider 的 `direction` 为 `ltr` 时 ColorPicker 仍应用 RTL
样式的问题。[#&#8203;59441](https://redirect.github.com/ant-design/ant-design/pull/59441)
[@&#8203;Chaoqi31](https://redirect.github.com/Chaoqi31)
- 🐞 修复 ColorPicker
数值输入框操作按钮宽度异常的问题。[#&#8203;59538](https://redirect.github.com/ant-design/ant-design/pull/59538)
[@&#8203;QDyanbing](https://redirect.github.com/QDyanbing)
- 🐞 修复嵌套 Descriptions
受到外层组件边框、间距和单元格布局影响的问题。[#&#8203;59547](https://redirect.github.com/ant-design/ant-design/pull/59547)
[@&#8203;xushanpei](https://redirect.github.com/xushanpei)
- 🐞 修复 Progress 线形进度条 `size` 传入字符串宽度(如 `['50%',
20]`)时不生效、始终撑满容器的问题。[#&#8203;59597](https://redirect.github.com/ant-design/ant-design/pull/59597)
[@&#8203;wfatih](https://redirect.github.com/wfatih)
- 🐞 修复 Tooltip 的 `borderRadius` token 大于 8 时,左右侧弹层圆角未限制为 8px
的问题。[#&#8203;59568](https://redirect.github.com/ant-design/ant-design/pull/59568)
[@&#8203;dogledogle](https://redirect.github.com/dogledogle)
- 🐞 修复点击 Popconfirm 弹层内容时 `onPopupClick`
被触发两次的问题。[#&#8203;59440](https://redirect.github.com/ant-design/ant-design/pull/59440)
[@&#8203;Chaoqi31](https://redirect.github.com/Chaoqi31)
- 🐞 修复 Upload 的 `showUploadList.extra` 为 `0` 或返回 `0`
时额外内容样式未生效的问题。[#&#8203;59438](https://redirect.github.com/ant-design/ant-design/pull/59438)
[@&#8203;Chaoqi31](https://redirect.github.com/Chaoqi31)
- ♿ 修复 Typography
默认编辑图标暴露重复按钮语义的问题。[#&#8203;59112](https://redirect.github.com/ant-design/ant-design/pull/59112)
[@&#8203;nrps9909](https://redirect.github.com/nrps9909)
- ⚡️ 优化 Transfer
左侧列表的渲染性能。[#&#8203;59524](https://redirect.github.com/ant-design/ant-design/pull/59524)
[@&#8203;QDyanbing](https://redirect.github.com/QDyanbing)

</details>

---

### Configuration

📅 **Schedule**: (in timezone Europe/Helsinki)

- Branch creation
  - "on monday"
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend Renovate
CLI](https://redirect.github.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNDMuMCIsInVwZGF0ZWRJblZlciI6IjQ0LjE0My4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->

Co-authored-by: thaw-release-bot[bot] <277444778+thaw-release-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants